﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using RGBFinder.Resources;


namespace RGBFinder
{
    public class MainViewModel : INotifyPropertyChanged
    {
        public MainViewModel()
        {

            this.Ads = new ObservableCollection<AdsViewModel>();
            this.Scores = new ObservableCollection<ScoresViewModel>();
            this.GameTypes = new ObservableCollection<GameTypeViewModel>();
        }

        /// <summary>
        /// A collection for ItemViewModel objects.
        /// </summary>



        public ObservableCollection<AdsViewModel> Ads { get; private set; }
        public ObservableCollection<ScoresViewModel> Scores { get; private set; }
        public ObservableCollection<GameTypeViewModel> GameTypes { get; private set; }

        private string _sampleProperty = "Sample Runtime Property Value";
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding
        /// </summary>
        /// <returns></returns>
        public string SampleProperty
        {
            get
            {
                return _sampleProperty;
            }
            set
            {
                if (value != _sampleProperty)
                {
                    _sampleProperty = value;
                    NotifyPropertyChanged("SampleProperty");
                }
            }
        }

        public bool IsDataLoaded
        {
            get;
            private set;
        }

        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            Ads.Add(new AdsViewModel() { Name = "Informa Treni", Description = Strings.InformaTreni_Desc, ID = MainPage.InformaTreni_ID, ImageUri = new Uri("/Images/Tiles/InformaTreni.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "Chaining Explosion", Description = Strings.ChainingExplosion_Desc, ID = MainPage.ChainingExplosion_ID, ImageUri = new Uri("/Images/Tiles/ChainingExplosion.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "Ebook Reader", Description = Strings.EbookReader_Desc, ID = MainPage.EbookReader_ID, ImageUri = new Uri("/Images/Tiles/EbookReader.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "Enigma Reloaded", Description = Strings.Enigma_Desc, ID = MainPage.Enigma_ID, ImageUri = new Uri("/Images/Tiles/Enigma.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "Tap Sequence", Description = Strings.TapSequence_Desc, ID = MainPage.TapSequence_ID, ImageUri = new Uri("/Images/Tiles/tap.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "BoardGameSuite", Description = Strings.BoardGameSuite_Desc, ID = MainPage.BoardGameSuite_ID, ImageUri = new Uri("/Images/Tiles/board.png", UriKind.RelativeOrAbsolute) });
            
            Ads.Add(new AdsViewModel() { Name = "IdeoPuzzle", Description = Strings.IdeoPuzzle_Desc, ID = MainPage.IdeoPuzzle_ID, ImageUri = new Uri("/Images/Tiles/IdeoPuzzle.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "TriangleShooter", Description = Strings.TriangleShooter_Desc, ID = MainPage.TriangleShooter_ID, ImageUri = new Uri("/Images/Tiles/TriangleShooter.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "SpaceBattle", Description = Strings.SpaceBattle_Desc, ID = MainPage.SapceBattle_ID, ImageUri = new Uri("/Images/Tiles/SpaceBattle.png", UriKind.RelativeOrAbsolute) });            
            Ads.Add(new AdsViewModel() { Name = Strings.OthersApps, Description = "", ID = "", ImageUri = new Uri("", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "MTG Score", Description = Strings.MTGScore_Desc, ID = MainPage.MTGScore_ID, ImageUri = new Uri("/Images/Tiles/MTGScore.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "MTG Cards", Description = Strings.MTGCards_Desc, ID = MainPage.MTGCards_ID, ImageUri = new Uri("/Images/Tiles/MTGCards.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "MTG Dice", Description = Strings.MTGDice_Desc, ID = MainPage.MTGDice_ID, ImageUri = new Uri("/Images/Tiles/MTGDice.png", UriKind.RelativeOrAbsolute) });
            Ads.Add(new AdsViewModel() { Name = "MTG Helps", Description = Strings.MTGHelps_Desc, ID = MainPage.MTGHelps_ID, ImageUri = new Uri("/Images/Tiles/MTGHelps.png", UriKind.RelativeOrAbsolute) });

            Scores.Add(new ScoresViewModel() { Time = Strings.Time, Tests = Strings.Tests, Score = Strings.Score, Name = Strings.Name, Index = Strings.Rank });

            GameTypes.Add(new GameTypeViewModel() { Name = Strings.Easy, Description = Strings.Easy_Desc });
            GameTypes.Add(new GameTypeViewModel());
            GameTypes.Add(new GameTypeViewModel() { Name = Strings.Normal, Description = Strings.Normal_Desc });
            GameTypes.Add(new GameTypeViewModel());
            GameTypes.Add(new GameTypeViewModel() { Name = Strings.Hard, Description = Strings.Hard_Desc });
            GameTypes.Add(new GameTypeViewModel());
            GameTypes.Add(new GameTypeViewModel() { Name = Strings.Reverse, Description = Strings.Reverse_Desc });

            this.IsDataLoaded = true;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}